package com.jianglin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jianglin.mapper.BuildingMapper;
import com.jianglin.model.Building;
import com.jianglin.service.IBuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BuildingServiceImpl implements IBuildingService {

    @Autowired
    private BuildingMapper buildingMapper;

    @Override
    public PageInfo<Building> findBuildAll(int page, int pageSize, String numbers) {
        PageHelper.startPage(page, pageSize);
        List<Building> list = buildingMapper.queryBuildAll(numbers);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<Building> findListByPage(Integer page, Integer pageCount) {
        PageHelper.startPage(page, pageCount);
        List<Building> list = buildingMapper.selectAll();
        return new PageInfo<>(list);
    }
    @Override
    public int add(Building building) {
        return buildingMapper.insert(building);
    }

    @Override
    public int delete(Long id) {
        return buildingMapper.deleteById(id);
    }

    @Override
    public int updateData(Building building) {
        return buildingMapper.update(building);
    }

    @Override
    public Building findById(Long id) {
        return buildingMapper.selectById(id);
    }

    @Override
    public Building queryBuildById(Integer buildId) {
        return buildingMapper.queryBuildById(buildId);
    }
}
